package org.axgl 
{
	import org.axgl.input.AxMouseButton;


public class AxRect extends AxPoint 
{
	public function AxRect(x:Number = 0, y:Number = 0, width:Number = 0, height:Number = 0) {
		super(x, y);
		this.width = width;
		this.height = height;
	}

	
	

	public function get left():Number {return x;}
	public function get right():Number {return x + width;}
	public function get top():Number {return y;}
	public function get bottom():Number {return y + height;}
	
	
	
	
	public function contains(x:Number, y:Number):Boolean
	{
		return x >= this.x && y >= this.y && x <= this.right && y <= this.bottom;
	}


	public function overlaps(other:AxRect):Boolean
	{
		return left + AxU.EPSILON < other.right && top + AxU.EPSILON < other.bottom && right - AxU.EPSILON > other.left && bottom - AxU.EPSILON > other.top;
	}


	public function hover():Boolean 
	{
		return contains(Ax.mouse.x, Ax.mouse.y);
	}


	public function clicked():Boolean 
	{
		return Ax.mouse.pressed(AxMouseButton.LEFT) && hover();
	}


	public function held():Boolean
	{
		return Ax.mouse.down(AxMouseButton.LEFT) && hover();
	}


	public function released():Boolean
	{
		return Ax.mouse.released(AxMouseButton.LEFT) && hover();
	}


	
	public var width:Number;
	public var height:Number;

}
}
